package com.wuming.house.service.impl;

import com.wuming.house.core.BusinessException;
import com.wuming.house.dao.HouseTagMapper;
import com.wuming.house.model.HouseTag;
import com.wuming.house.service.HouseTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("houseTagService")
public class HouseTagServiceImpl implements HouseTagService {

    @Autowired
    private HouseTagMapper houseTagMapper;

    @Override
    public void saveHouseTag(HouseTag houseTag) throws BusinessException {
        houseTagMapper.insert(houseTag);
    }

    @Override
    public List<HouseTag> getHouseTagByHouseId(Long houseId, Integer houseType) throws BusinessException {
        Map<String, Object> params = new HashMap<>();
        params.put("houseId", houseId);
        if (null != houseType) {
            params.put("houseType", houseType);
        }
        return houseTagMapper.selectTagByHouse(params);
    }

    @Override
    public void removeHouseTag(Long id) throws BusinessException {
        houseTagMapper.deleteByPrimaryKey(id);
    }
}
